//表单配置的js api
import request from "@/utils/request";

/**
 * 查询清单列表分页数据
 * @param {*} params
 */
export function queryPages(params) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH + "/yxpz/handleDetailList/queryPages",
    method: "get",
    params: params
  });
}

// 获取事项表单详情
export function getSxSerFormByOid(sxSerFormOid) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/yxpz/serForm/getSxSerFormByOid?sxSerFormOid=" +
      sxSerFormOid,
    method: "get"
  });
}

//查询列表 - serviceOid
export function getSerFormList(params) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/yxpz/serForm/getSerFormsByServiceOid",
    method: "get",
    params: params
  });
}

// 事项表单关联保存或者修改
export function save(data) {
  return request({
    url: process.env.VUE_APP_KSTB_ROUTE_PATH + "/yxpz/serForm/save",
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    },
    data: data
  });
}

// 启禁用表单信息
export function sxSerFormAble(oid) {
  return request({
    url: process.env.VUE_APP_KSTB_ROUTE_PATH + "/yxpz/serForm/sxSerFormAble",
    params: {
      oid: oid
    },
    method: "post"
  });
}

/**
 * 查询清单下面是否存在已启用的表单
 * @param {*} hdlOid
 * @return true 存在 false 不存在
 */
export function hasExistAble(hdlOid) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/yxpz/serForm/hasExistAble/${hdlOid}`,

    method: "post"
  });
}

/**
 * 根据业务主键删除数据
 * @param {*} oid
 *
 */
export function deleteByOid(oid) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH + `/yxpz/serForm/deleteByOid/${oid}`,

    method: "post"
  });
}

//查询表单类别列表
export function listFormClassify(params) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH + "/yxpz/formClassify/formClassifys",
    method: "get",
    params: { params }
  });
}

/**
 * 查询清单可以选择的表单分类
 * @param {*} hdlOid
 */
export function queryListFormClassifyByHdlOid(hdlOid = "", serFormOid = "") {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/yxpz/formClassify/queryListFormClassifyByHdlOid",
    method: "get",
    params: {
      hdlOid,
      serFormOid
    }
  });
}

/**
 * 根据清单hdloid查询需要填报的表单数据
 * @param {*} hdlOid
 */
export function queryAbleByHdlOid(hdlOid = "") {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/yxpz/sxSerForm/queryAbleByHdlOid/${hdlOid}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}

/**
 * 根据办件caseoid查询填写的表单数据
 */
export function viewQueryAbleByCaseOid(caseOid = "") {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/yxpz/sxSerForm/viewQueryAbleByCaseOid/${caseOid}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}

/**
 * 根据caseOid查询已经填写的表单数据
 * @param {*} caseOid
 */
export function queryByCaseOid(caseOid) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/caseForm/queryByCaseOid/${caseOid}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}

/**
 *根据serFormOid和formCode查询是否存在启用的
 * @param {*} serFormOid
 * @param {*} formCode
 * @returns
 */
export function hasExistSerFormOidAndFormCodeAble(serFormOid, formCode) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/yxpz/sxSerForm/hasExistSerFormOidAndFormCodeAble",
    method: "get",
    params: {
      serFormOid,
      formCode
    }
  });
}
